<!--conf
<sample>
              <product version="1.4" edition="pro"/>
                     <modifications>
                            <modified date="070101"/>
                     </modifications>
               </sample>
 --> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Date/Decimal format</title>
	


    	<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
		<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid_skins.css">
    <script>_css_prefix="../../codebase/"; _js_prefix="../../codebase/"; </script>
	<script  src="../../codebase/dhtmlxcommon.js"></script>
	<script  src="../../codebase/dhtmlxgrid.js"></script>
	<script  src="../../codebase/dhtmlxgridcell.js"></script>
	<script  src="../../codebase/excells/dhtmlxgrid_excell_calck.js"></script>
	<script  src="../../codebase/excells/dhtmlxgrid_excell_acheck.js"></script>
	<script  src="../../codebase/excells/dhtmlxgrid_excell_calendar.js"></script>
	<script  src="../../codebase/excells/dhtmlxgrid_excell_clist.js"></script>
</head>

<body>
<link rel='STYLESHEET' type='text/css' href='../common/style.css'>
<table cellspacing="0" cellpadding="0" class="sample_header" border="0">
	<tr valign="middle">
		<!-- COMPONENT ICON -->
		<td width="40" align="center"><img src="../common/dhtmlxgrid_icon.gif" border="0"></td>
		<!-- COMPONENT NAME -->
		<td width="150" align="left" nowrap="true">Sample: dhtmlxGrid</td>
		<!-- SAMPLE TITLE -->
		<td width="0" align="left" nowrap><b>Date/Decimal format</b></td>
		<!-- LINK TO COMPONENT PAGE -->
		<td width="0" align="right"><a href="http://www.dhtmlx.com/docs/products/dhtmlxGrid/index.shtml">dhtmlxGrid main page</a></td>
		<!-- CLOSE BUTTON -->
		<td width="50"><div class="sample_close"><a href="javascript:void(0);" onclick="self.close();"><img src="../common/sample_close.gif" width="14" height="14" border="0" alt="X"></a></div></td>
	</tr>
</table>
	
	
	
	<p>You can set Date and Decimal number formats using setDateFormat and setNumberFormat methods</p>
	
	
				<div id="gridbox" width="452px" height="215px" style="background-color:white;"></div>
		
    <script>
        //extended simple editor (with number format support) to use color for numbers
		function eXcell_edncl(cell){
			this.base = eXcell_edn;
			this.base(cell)
			this.setValue = function(val){
					if(!val || val.toString()._dhx_trim()=="")
						val="0"
					if(val>=0)
						this.cell.style.color = "green";
					else
						this.cell.style.color = "red";
					this.cell.innerHTML = this.grid._aplNF(val,this.cell._cellIndex);
			}
		
		}
		eXcell_edncl.prototype = new eXcell_edn;
		
		//extended simple editor (with number format support) to be readonly
		function eXcell_ednro(cell){
			this.base = eXcell_edn;
			this.base(cell)
			this.edit = function(){
				return false;
			}
			this.detach = function(){
				return false;
			}
		}
		eXcell_ednro.prototype = new eXcell_edn;
    </script>

<div class='sample_code'><div class="hl-main"><pre><span class="hl-code"> 
</span><span class="hl-brackets">&lt;</span><span class="hl-reserved">div</span><span class="hl-code"> </span><span class="hl-var">id</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">gridbox</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">width</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">100%</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">height</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">250px</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">style</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">background-color:white;overflow:hidden</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">&gt;</span><span class="hl-brackets">&lt;/</span><span class="hl-reserved">div</span><span class="hl-brackets">&gt;</span><span class="hl-code">
</span><span class="hl-brackets">&lt;</span><span class="hl-reserved">script</span><span class="hl-brackets">&gt;</span><span class="hl-code"><div class="hl-main"><pre><span class="hl-code"> 
    </span><span class="hl-identifier">mygrid</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">dhtmlXGridObject</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">gridbox</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">setColTypes</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">edncl,ednro,calendar</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;
    ...
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">setNumberFormat</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">%script%0.00</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-number">1</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">setNumberFormat</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">0,000</span><span class="hl-quotes">&quot;</span><span class="hl-code">,</span><span class="hl-number">0</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">setDateFormat</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">m-d-y</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">; 
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">init</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">loadXML</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">grid_format.xml</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;</span></pre></div></span><span class="hl-brackets">&lt;/</span><span class="hl-reserved">script</span><span class="hl-brackets">&gt;</span></pre></div></div>

<script>
	mygrid = new dhtmlXGridObject('gridbox');
	mygrid.setImagePath("../../codebase/imgs/");
	mygrid.setHeader("N.format colored,N.format readonly, Date");
	mygrid.setInitWidths("150,150,150")
	mygrid.setColAlign("right,right,right")
	mygrid.setColTypes("edncl,ednro,calendar");
    mygrid.setNumberFormat("$0,000",0);
    mygrid.setNumberFormat("@000.00Zbh",1);
	mygrid.setDateFormat("m-d-y") 
	mygrid.setColSorting("int,int,date")
	mygrid.init();
	mygrid.setSkin("modern")
	mygrid.loadXML("grid_format.xml");
</script>

<!-- FOOTER -->
<table callspacing="0" cellpadding="0" border="0" class="sample_footer"><tr><td style="padding-left: 8px;">&copy; <a href="http://www.dhtmlx.com">DHTMLX LTD</a>. All rights reserved</td></tr></table>
<!-- FOOTER -->

</body>
</html>
